  cd  "/Users/K1801607/Dropbox/BolognaRR/"   

use "dta/ESS_clean.dta", clear

 
 keep if University==1
 keep if short==1
 
 drop if Edu_field==.

g Science=0 
replace Science=1 if Edu_field==4 |  Edu_field==5 |  Edu_field==7  |  Edu_field== 14 

g Humanities=0 
replace Humanities=1 if Edu_field==2 |  Edu_field==3
 
g SocialS=0  
replace SocialS=1 if Edu_field==9 |  Edu_field==10 |  Edu_field==11 |  Edu_field==12 |  Edu_field==13 |  Edu_field==12 

g Health=0  
replace Health=1 if Edu_field==8   

 
la var Science "Science"
la var Humanities "Humanities"
la var SocialS "Social science"
la var Health "Medicine/health"



** Running the Meritocracy Regressions
quietly eststo m1: reg Meritocracy Bologna c.Bologna#c.Science Science Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m2: reg Meritocracy Bologna c.Bologna#c.Humanities Humanities Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m3: reg Meritocracy Bologna c.Bologna#c.SocialS SocialS Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m4: reg Meritocracy Bologna c.Bologna#c.Health Health Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)


** Running the Consumerism Regressions
quietly eststo m5: reg Consumerism Bologna c.Bologna#c.Science Science Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m6: reg Consumerism Bologna c.Bologna#c.Humanities Humanities Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m7: reg Consumerism Bologna c.Bologna#c.SocialS SocialS Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m8: reg Consumerism Bologna c.Bologna#c.Health Health Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

 
** Creating a single LaTeX table with esttab for both Meritocracy and Consumerism (Revised)
esttab m1 m2 m3 m4 m5 m6 m7 m8  using "Tables/FieldA2.tex", ///
    drop(trend *.Country *.essround *.yrbrn _cons  Female Citizen Health SocialS Humanities Science ) ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    stats(N, fmt(%9.0fc) labels("N. Obs")) ///
    booktabs label nomtitles   mgroups("\shortstack{Achievement (status)}" "\shortstack{Achievement  (wealth)}", pattern(0  0  0 0 1 0 0   0) prefix(\multicolumn{@span}{c}{) suffix(})  span erepeat(\cmidrule(lr){@span}))  ///
    title("\scshape Heterogeneity by field of studies (Personal achievement)") ///
    order(Bologna c.Bologna#c.Science c.Bologna#c.Humanities c.Bologna#c.SocialS  c.Bologna#c.Health ) ///
    replace

 

** Running the Meritocracy Regressions
quietly eststo m1: reg Equality Bologna c.Bologna#c.Science Science Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m2: reg Equality Bologna c.Bologna#c.Humanities Humanities Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m3: reg Equality Bologna c.Bologna#c.SocialS SocialS Female Citizen trend i.Country i.essround   i.yrbrn  if University==1  , vce(cluster Country)

quietly eststo m4: reg Equality Bologna c.Bologna#c.Health Health Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)


** Running the Consumerism Regressions

quietly eststo m5: reg Environment Bologna c.Bologna#c.Science Science Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m6: reg Environment Bologna c.Bologna#c.Humanities Humanities Female Citizen  trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m7: reg Environment Bologna c.Bologna#c.SocialS SocialS Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)

quietly eststo m8: reg Environment Bologna c.Bologna#c.Health Health Female Citizen trend i.Country i.essround   i.yrbrn  if University==1 , vce(cluster Country)
 
** Creating a single LaTeX table with esttab for both Meritocracy and Consumerism  
esttab m1 m2 m3 m4 m5 m6 m7 m8  using "Tables/FieldB2.tex", ///
    drop(trend *.Country *.essround *.yrbrn _cons  Female Citizen Health SocialS Humanities Science ) ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    stats(N, fmt(%9.0fc) labels("N. Obs")) ///
    booktabs label nomtitles   mgroups("\shortstack{Justice (equality)}" "\shortstack{Justice (environment)}", pattern(0  0  0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(})  span erepeat(\cmidrule(lr){@span}))  ///
    title("\scshape Heterogeneity by field of studies (Global justice)") ///
    order(Bologna c.Bologna#c.Science c.Bologna#c.Humanities c.Bologna#c.SocialS  c.Bologna#c.Health) ///
    replace

 